package classes;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Test {
	public static void main(String[] args) throws ParseException {
		Date d = new Date();
		System.out.println(d); //周几 月份 日期 时间 什么时间  年
		
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss a");
		String format2 = format.format(d);
		System.out.println(format2);
		
		// 字符串转日期
		String s = "2023-02-03 16:30:32 下午";
		Date parse = format.parse(s);
		System.out.println(parse);
		
		BigInteger i1 = new BigInteger("123131321321312313123131322131313131313123");
		BigInteger i2 = new BigInteger("123131321321312313123131322131313131313123");
		System.out.println(i1.add(i2));
		System.out.println(i1.subtract(i2));
		System.out.println(i1.multiply(i2));
		System.out.println(i1.divide(i2));
		
		BigDecimal i3 = new BigDecimal("123131321321312313123.131322131313131313123");
		BigDecimal i4 = new BigDecimal("123131321321312313123.131322131313131313123");
		System.out.println(i3.add(i4));
		System.out.println(i3.subtract(i4));
		System.out.println(i3.multiply(i4));
		System.out.println(i3.divide(i4));
		
		String binaryString = Integer.toBinaryString(12345);
		System.out.println(binaryString);
		
		
		// 明年的2月最后一天是否是周一
		Calendar c = Calendar.getInstance();
		// 年份加1   2024，2，3
		c.add(Calendar.YEAR, 1);   
		// 月份加1   2024, 3, 3
		c.add(Calendar.MONTH, 1);
		// 设定日期1号  2024, 3,1
		c.set(Calendar.DAY_OF_MONTH, 1);
		// 减去1天
		c.add(Calendar.DAY_OF_YEAR, -1);
		
		System.out.println(c.get(Calendar.YEAR));
		System.out.println(c.get(Calendar.MONTH) + 1);
		System.out.println(c.get(Calendar.DAY_OF_MONTH));
		
		System.out.println(c.get(Calendar.DAY_OF_WEEK) == Calendar.THURSDAY);
		
	}
}
